import { dayjs } from 'element-plus'
import cn from 'dayjs/locale/zh-cn'
import relativeTime from 'dayjs/plugin/relativeTime'

dayjs.locale(cn)
dayjs.extend(relativeTime)




export function formatTimeUnixToNow(t) {
  return dayjs(t * 1000).fromNow(true) + "前"
}

export function formatTimeUnix(t) {
  return dayjs(t * 1000).format('YYYY:MM:DD HH:mm:ss')
}

export function formatCreateTime(t) {
  return dayjs(t.CreateTime * 1000).format('YYYY:MM:DD HH:mm:ss')
}

export function formatAppointmentTime(t) {
  return dayjs(t.AppointmentTime * 1000).format('YYYY:MM:DD HH:mm')
}
export function formatStopTime(t) {
  return dayjs(t.StopTime * 1000).format('YYYY:MM:DD HH:mm')
}
export function formatStartTime(t) {
	if (t.StartTime == 0) {
		return "未开始"
	}
  return dayjs(t.StartTime * 1000).format('YYYY:MM:DD HH:mm:ss')
}
export function formatEndTime(t) {
	if (t.EndTime == 0) {
		return "未结束"
	}
  return dayjs(t.EndTime * 1000).format('YYYY:MM:DD HH:mm:ss')
}


export function getTime() {
  return dayjs().format('YY年MM月DD日HH:mm:ss导入商品-')
}



const userTypeMap = {
	admin: '管理员',
	expert: '专家',
	common: '教师',
}
export function formatUserType(user) {
	return userTypeMap[user] || "未知"
}

const opStatusMap = {
	0: "正常",
	1: "异常",
}

export function formatOpStatus(item) {
	return opStatusMap[item.status] || "未知"

}

const opTypeMap = {
	0: "其他",
	1: "后台用户",
	2: "手机用户",
}

export function formatOpType(item) {
	return opTypeMap[item.operatorType] || "未知"

}


const opBussMap = {
	1: "新增",
	2: "修改",
	3: "删除",
	4: "授权",
	5: "导出",
	6: "导入",
	7: "强退",
	8: "生成代码",
	9: "清空数据",
}

export function formatBuStatus(item) {
	return opBussMap[item.businessType] || "未知"

}

const userStatusMap = {
	0: "正常",
	1: "锁定",
}

export function formatUserStatus(user) {
	return userStatusMap[user] || "未知"

}

const userStatusTagMap = {
	0: "success",
	1: "danger",
}

export function formatTagUserStatus(user) {
	return userStatusTagMap[user] || "info"

}

const itemStatusMap = {
	"success": "成功",
	"failed": "失败",
	"unknow": "未知",
}

const itemStatusTagMap = {
	"success": "success",
	"failed": "danger",
	"unknow": "info",
}
export function formatItemStatus(status) {
	return itemStatusMap[status] || "未知"
}

export function formatItemStatusType(status) {
	return itemStatusTagMap[status] || "default"
}

const itemTypeMap = {
	"text": "文本",
	"img": "图片",
	"file": "文件",
}
export function formatItemType(value) {
	return itemTypeMap[value.ItemType] || "其他"
}

// const userTypeMap = {
// 	"admin": "管理员",
// 	"personnel": "专业用户",
// 	"user": "普通用户",
// }

export function formatUserType2(value) {
	return userTypeMap[value.UserType] || "其他"

}


const useStepMap = {
	"undo": "领取任务未开始",
	"doing": "补贴任务进行中",
	"done": "补贴领取完成",
}
export function formatUserStepType(value) {
	return useStepMap[value.Step] || "其他"
}

const usedMap = {
	"used": "已使用",
	"unused": "未使用",
}
export function formatUsedType(value) {
	return usedMap[value.Status] || "其他"
}

const analyzeStatusMap = {
	0: "等待分析",
	1: "分析中",
	2: "失败", 
	3: "成功",
}
export function formatAnalyzeStatus(status) {
	return analyzeStatusMap[status] || "其他"
}

const tagAnalyzeStatusMap = {
	0: "info",
	1: 'warning',
	2: "danger", 
	3: "success",
}
export function formatTagAnalyzeStatus(status) {
	return tagAnalyzeStatusMap[status] || "info"
}

const skillTypeMap = {
	1: "通用技能",
	2: "核心技能", 
}
export function formatSkillType(status) {
	return skillTypeMap[status] || "其他"
}

const tagSkillTypeMap = {
	1: '',
	2: "success",
}
export function formatTagSkillType(status) {
	return tagSkillTypeMap[status] || ""
}


const skillStatus = {

   3: '审核通过',
   2: '待审核',
   1: '未提交',
}
export function formatSkillStatus(status) {
	return skillStatus[status] || "其他"
}

const tagSkillStatusMap = {
	1: "info",
	2: 'warning',
	3: "success",
}
export function formatTagSkillStatus(status) {
	return tagSkillStatusMap[status] || "info"
}



const taskstatusMap = {
	"undo": "未开始",
	"doing": "进行中",
	"done": "完成",
	"failed": "失败",
	"timeout": "超时",
}
export function formatTaskStatusType(value) {
	return taskstatusMap[value.Status] || "其他"
}